//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<expose_graphics_to_python.cpp>
///	@path	~/src/python/wrap/
///	@date	2008/12/08
///	@brief	.

#include "python_pre.h"

#include "lib/utilities/observer.h"

#include "graphics/IModel.h"
#include "graphics/IGeometry.h"
#include "graphics/IView.h"
#include "graphics/ITexture.h"

#include "graphics/xmodel/CBasicModel.h"
#include "graphics/common/COrthoView.h"
#include "graphics/common/CPerspectiveView.h"

using namespace xeres;

#include "python/wrap/expose_decl_python.h"

namespace xeres {

	static void expose_graphics( void )
	{
		//////////////////////////////////////////////////////////////////////////
		// View
		class_< IView , bases< IObject > , noncopyable >( "IView" , no_init )
			.add_property( "transform" , &IView::GetTransform )
			.add_property( "projection" , &IView::GetProjection )
		;
		register_ptr_to_python< Ref<IView> >();
		register_object_to_python<IView>();

		// perspective view
		class_< CPerspectiveView , Ref<CPerspectiveView> , bases< IView > , noncopyable >( "CPerspectiveView" , init<>() )
			// Property
			.add_property( "fov" , &CPerspectiveView::GetFov , &CPerspectiveView::SetFov )
			.add_property( "near" , &CPerspectiveView::GetNear , &CPerspectiveView::SetNear )
			.add_property( "far" , &CPerspectiveView::GetFar , &CPerspectiveView::SetFar )
			// Methods
			.def( "LookAt" , &CPerspectiveView::LookAt )
			.def( "SetProjection" , &CPerspectiveView::SetProjection )
			.def( "SetTransform" , &CPerspectiveView::SetTransform )
		;
		register_object_to_python<CPerspectiveView>();

		// orthographic view
		class_< COrthoView , Ref<COrthoView> , bases< IView > , noncopyable >( "COrthoView" , init<>() )
			// Property
			.add_property( "near" , &COrthoView::GetNear , &COrthoView::SetNear )
			.add_property( "far" , &COrthoView::GetFar , &COrthoView::SetFar )
			// Methods
			.def( "LookAt" , &COrthoView::LookAt )
			.def( "SetViewport" , &COrthoView::SetViewport )
			.def( "SetTransform" , &COrthoView::SetTransform )
		;
		register_object_to_python<COrthoView>();

		//////////////////////////////////////////////////////////////////////////
		// Device resource
		class_< IDeviceResource , bases< IObject > , noncopyable >( "IDeviceResource" , no_init )
		;
		register_ptr_to_python< Ref<IDeviceResource> >();
		register_object_to_python<IDeviceResource>();

		//////////////////////////////////////////////////////////////////////////
		// Geometry
		class_< IGeometry , bases< IDeviceResource > , noncopyable >( "IGeometry" , no_init )
		;
		register_ptr_to_python< Ref<IGeometry> >();
		register_object_to_python<IGeometry>();

		//////////////////////////////////////////////////////////////////////////
		// Model
		class_< IModel , bases< IObject > , noncopyable >( "IModel" , no_init )
		;
		register_ptr_to_python< Ref<IModel> >();
		register_object_to_python<IModel>();
	}

	namespace
	{
#define __declspec(X)

		BOOST_PYTHON_MODULE( xeres_graphics )
		{
			expose_graphics();
		}

#undef __declspec
	}

	void expose_graphics_to_python( void )
	{
		PythonPlug::instance().RegisterModule( "xeres" , init_module_xeres_graphics );
	}

} // namespace xeres
